import os
import json

#把一个txt文本转换成一个json数组数据；每一行一个元素；去除元素前后空白

ROOT_PATH = os.path.split(__file__)[0]
DIST_PATH = os.path.join(ROOT_PATH,'dist')

fileName = os.path.join(DIST_PATH,"filterChat.txt")
with open(fileName,"r",encoding="utf8") as f:
    lines = f.readlines()    
    lines = [ lines[k].strip() for k in range(len(lines)) if lines[k]!=""]            
    fileName = os.path.join(DIST_PATH,"filterChat.json")
with open(fileName,"w",encoding="utf8") as f:
    js = json.dumps(lines,ensure_ascii=False)
    f.write(js)